package org.zoomdev.zoom.dao.meta;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class TableKeyMeta {

    private final Map<String, ColumnTypeMeta> map = new HashMap<>();
    private String name;
    private ColumnTypeMeta[] primaryKeys;
    private ColumnTypeMeta[] columns;

    public ColumnTypeMeta[] getPrimaryKeys() {
        return primaryKeys;
    }

    public void setPrimaryKeys(String[] pks) {
        this.primaryKeys = Arrays.stream(pks).map(map::get)
                .toArray(ColumnTypeMeta[]::new);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ColumnTypeMeta[] getColumns() {
        return columns;
    }

    public void setColumns(ColumnTypeMeta[] columns) {
        this.columns = columns;
        for (ColumnTypeMeta meta : columns) {
            map.put(meta.getName(), meta);
        }
    }
}
